package itbour.onetouchshow.activity.userinfo;

import com.lsjr.callback.EncryBeanCallBack;
import com.lsjr.utils.HttpUtils;

import java.util.HashMap;

import itbour.onetouchshow.base.mvp.BasePresenterImpl;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.constants.AppConst;
import itbour.onetouchshow.utils.L_;

/**
 * Created by guoh on 2018/3/27.
 * 功能描述：
 * 需要的参数：
 */

public class XiuMiDetailPresenter extends BasePresenterImpl<XiuMiDetailContract.View> implements XiuMiDetailContract.Presenter {


    public void getUserBalance(int userId) {
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("device", AppConst.ANDROID_DEVICE);
        stringObjectHashMap.put("userId", userId);
        HttpUtils.getInstance().executeGet(AppConfig.GET_USER_BALANCE, stringObjectHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                L_.e(exception);
                if (mvpView != null) {
                    mvpView.loadFaild(exception);
                }
            }

            @Override
            protected void onSuccess(String response) {
                L_.e(response);
                L_.e("秀米余额" + response);
                if (mvpView != null) {
                    mvpView.loadBalanceSuccess(response);
                }
            }
        });
    }


    public void getBalanceRecord(int userId, int pageNum, int pageSize) {
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("device", AppConst.ANDROID_DEVICE);
        stringObjectHashMap.put("userId", userId);
        stringObjectHashMap.put("pageNum", pageNum);
        stringObjectHashMap.put("pageSize", pageSize);
        stringObjectHashMap.put("types", "[1,2]");
        stringObjectHashMap.put("withTotalPage", "1");
        HttpUtils.getInstance().executeGet(AppConfig.GET_POINTSDETAIL_LIST, stringObjectHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                L_.e(exception);
                mvpView.loadFaild(exception);
            }

            @Override
            protected void onSuccess(String response) {
                L_.e(response);
                L_.e("秀米记录" + response);
                if (mvpView != null) {
                    mvpView.loadSucceed(response);
                }
            }
        });
    }


}
